/*
 * @Author: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @Date: 2025-10-26 21:23:00
 * @LastEditors: 来自火星的码农 15122322+heyzhi@user.noreply.gitee.com
 * @LastEditTime: 2025-10-28 16:45:55
 * @FilePath: /GateServer/src/statusclient/statusconpool.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once

#include <atomic>
#include <condition_variable>
#include <cstddef>
#include <grpcpp/channel.h>
#include <memory>
#include <mutex>
#include <queue>
#include "iostream"
#include "grpcpp/grpcpp.h"
#include "../../build/message.grpc.pb.h"
#include "../../build/message.pb.h"
namespace Yizhi {
    class StatusConPool{
        public:

        StatusConPool(const std::string& host,int port,size_t poolsize);
        ~StatusConPool();
        std::unique_ptr<message::GetStatusService::Stub> Getconnection();
        void ReturnCon(std::unique_ptr<message::GetStatusService::Stub> con);
        void close();

        private:
        std::atomic<bool> m_stop;
        std::string  m_host;
        int m_port;
        size_t m_poolsize;

        std::queue<std::unique_ptr<message::GetStatusService::Stub>> m_cons;

        std::mutex m_mutex;
        std::condition_variable m_cond;

    };
}